open(BUFF,"chr22_out_ori.tped") or die "chr22_out_ori.tped no file exists\n";
open(BUFF1,"beagle_final.txt") or die " beagle_final.txt file not exists\n";
while(<BUFF>)
{
        $line = <BUFF1>;
        chomp($_);
        chomp($line);
        @array = split(" ",$_);
	shift(@array);
	$rsid=shift(@array);
	shift(@array);
	shift(@array);
        @array1 = split(" ",$line);
	$rsid1=shift(@array1);
        if($rsid eq $rsid1)
        {
                print "$rsid";
                $n=0;
		$m=0;
                for($i = 0;$i<@array;$i++)
                {
                        $val1 = $array[$i];
                        $val3 = $array1[$i];
                        $i++;
                        $val2 = $array[$i];
                        $val4 = $array1[$i];
			#die "$val1 $val2  $val3 $val4\n";
			if($val1 ne "0" && $val2 ne "0")
			{
				$m++;
                        	if(($val1 eq $val3 && $val2 eq $val4)||($val1 eq $val4 && $val2 eq $val3))
                        	{
                                	$n++;
                        	}
			}
                }
		$temp = ($n/$m)*100;
                print " $n $m $temp\n";
        }
	else
	{
		print "$rsid ne $rsid1\n";
	}
}

